class CertificatesController < InheritedResources::Base
  respond_to :json
  load_resource

  def create
    @certificate = AddCertificate.run(permitted_params[:certificate])
    render CommandJsonSerializer.as_json(@certificate)
  end

  def require_organs
    respond_with PositionCertificateStandard.find_require_organ_by_certificate @certificate
  end

  def analysis
    respond_with CertificateJsonSerializer.analysis_as_json Certificate.all
  end

  private
  def permitted_params
    params.permit(:certificate => [:name, :available_months, :initiate_cost, :recheck_cost, :recheck_time])
  end

end